package com.luyu.resp;

/**
 * @Author lyh
 */
public class ResponseResult<T> {



    private String code;
    private String errorCode;
    private String msg;
    private T data;

    public ResponseResult() {
    }

    public ResponseResult(String code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ResponseResult(String code, String msg, String errorCode, T data) {
        this.code = code;
        this.msg = msg;
        this.errorCode = errorCode;
        this.data = data;
    }

    public static <T> ResponseResult<T> SUCCESS() {
        ResponseResult<T> r = new ResponseResult<T>();
        r.setCode("200");
        return r;
    }

    public static <T> ResponseResult<T> SUCCESS(T data) {
        ResponseResult<T> r = new ResponseResult<T>();
        r.setCode("200");
        r.setData(data);
        return r;
    }


    public static <T> ResponseResult<T> ERROR(String code, String errorCode, String msg) {
        ResponseResult<T> r = new ResponseResult<T>();
        r.setCode(code);
        r.setCode(errorCode);
        r.setMsg(msg);
        return r;
    }



    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode == null ? null : errorCode.trim();
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
